-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix/simplify lazy initialization #108
Conversation
…move it later, among with many others
/** | ||
* @return [FingerprintingSignalsProvider] which is useful in conjunction with the getFingerprint(signals, hasher) method. | ||
* @return [FingerprintingSignalsProvider] which is useful in conjunction with the getFingerprint(signals, hasher) method, or null |
Check warning
Code scanning / detekt
Line detected that is longer than the defined maximum line length in the code style. Warning
@@ -0,0 +1,10 @@ | |||
package com.fingerprintjs.android.fingerprint.tools |
Check warning
Code scanning / detekt
Checks whether files end with a line separator. Warning
|
||
@Test | ||
fun flattenOuterErrorReturned() { | ||
val res = runCatching { runCatching { 0 }.also { throw Exception() } }.flatten() |
Check warning
Code scanning / detekt
Thrown exception is too generic. Prefer throwing project specific exceptions to handle error cases. Warning test
|
||
@Test | ||
fun flattenInnerErrorReturned() { | ||
val res = runCatching { runCatching { 0.also { throw Exception() } } }.flatten() |
Check warning
Code scanning / detekt
Thrown exception is too generic. Prefer throwing project specific exceptions to handle error cases. Warning test
@@ -0,0 +1,29 @@ | |||
package com.fingerprintjs.android.fingerprint |
Check warning
Code scanning / detekt
Checks whether files end with a line separator. Warning test
// defaults from Executors.newCachedThreadPool() | ||
ThreadPoolExecutor( | ||
0, Integer.MAX_VALUE, | ||
60L, TimeUnit.SECONDS, |
Check warning
Code scanning / detekt
Report magic numbers. Magic number is a numeric literal that is not defined as a constant and hence it's unclear what the purpose of this number is. It's better to declare such numbers as constants and give them a proper name. By default, -1, 0, 1, and 2 are not considered to be magic numbers. Warning
activityManager = safeLazy { context.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager }, | ||
internalStorageStats = safeLazy { StatFs(Environment.getRootDirectory()!!.absolutePath!!) }, | ||
externalStorageStats = safeLazy { | ||
activityManager = safe { context.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager }.getOrNull(), |
Check warning
Code scanning / detekt
Line detected that is longer than the defined maximum line length in the code style. Warning
@@ -107,7 +105,7 @@ class SafeTests { | |||
val errLvl1: Throwable? | |||
var errLvl2: Throwable? = null | |||
var errLvl3: Throwable? = null | |||
val countDownLatch = CountDownLatch(1) | |||
val countDownLatch = CountDownLatch(2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not related to other changes. This is just to avoid a race condition
Simplified safe lazy initialization. All factory code is now run lazily instead of only some of it's parts.
With this change, the return type of
getFingerprintingSignalsProvider()
inevitably became nullable.